/*
 * Name: Joon Ho Cho
 * Date: 10/24/2008
 * Course: 15-437
 */
package scheduler.model;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

public class Model {
    private UserDao  userDao;
    private CourseDao  courseDao;
    private LectureDao  lectureDao;
    private ScheduleDao scheduleDao;
 //   private SavedScheduleDao savedScheduleDao;
    private SectionDao  sectionDao;
    private BookmarkDao  bookmarkDao;
    
	public Model(ServletConfig config) throws ServletException {
		try {
		    String jdbcDriver = config.getInitParameter("jdbcDriverName");
		    String jdbcUrl    = config.getInitParameter("jdbcURL");
	    	    
		    userDao = new UserDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    courseDao = new CourseDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    lectureDao = new LectureDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    scheduleDao = new ScheduleDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		   // savedScheduleDao = new SavedScheduleDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    sectionDao = new SectionDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    bookmarkDao = new BookmarkDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		} catch (Throwable t) {
		    throw new ServletException(t);
		}
	}

    public UserDao getUserDao() {
        return userDao;
    }
    
    public CourseDao getCourseDao() {
        return courseDao;
    }
    
    public LectureDao getLectureDao() {
        return lectureDao;
    }
    
    public ScheduleDao getScheduleDao() {
        return scheduleDao;
    }
    

    
    public SectionDao getSectionDao() {
        return sectionDao;
    }
    
    public BookmarkDao getBookmarkDao() {
        return bookmarkDao;
    }
}
